// pages/productDetail/productDetail.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },
  
  /**
   * 组件的初始数据
   */
  data: {
    imgUrls: [
      '../../resource/image/jd1.jpg',
      '../../resource/image/jd2.jpg'
    ],
    number:1,
    ddd: 4,
    scact: false,
    layact:false,
    scrollnum:0,
    shangpingHeight:0,
    pinlunHeight: 0,
    xiangqinHeight:0,
    headHeight: 0,
    pinlun:[
      { 
        tx: '../../resource/image/jd2.jpg', 
        name: '风吹麦浪', dj: "二级会员", 
        time: "2018-06-06", 
        txt: "今刚收到货，油质不错，金黄金黄的，买的非转基因的玉米油，价格还好，不算太贵，值得信赖，很好很棒！",
         star: 4,
          product: '金龙鱼油5L', 
          reply:'感谢亲对我们的大力支持！感谢亲对我们的大力支持！',
        imglist: [
          'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
          'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
          'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg',
          'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
          'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
          'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
          ]
          }
    ],
    guige:[
      {
        guigename:'特征1',
        tzlist: [
          { tzname: '特征1-1', checked:false},
          { tzname: '特征1-2', checked: false },
          { tzname: '特征1-3', checked: false },
        ]
      },
      {
        guigename: '特征22',
        tzlist: [
          { tzname: '特征22-1', checked: false },
          { tzname: '特征22-22', checked: false },
          { tzname: '特征22-3333', checked:false },
        ]
      },
    ]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onLoad: function (options) {
      console.log(options.id)
      var _this = this;
      //创建节点选择器
      var query = wx.createSelectorQuery();
      var query2 = wx.createSelectorQuery();
      var query3 = wx.createSelectorQuery();
      var query4 = wx.createSelectorQuery();
      //选择id
      query.select('.shangping').boundingClientRect()
      query.exec(function (res) {
        //res就是 该元素的信息 数组
        console.log(res);
        //取高度
        _this.setData({
          shangpingHeight: res[0].height
        })
        console.log( _this.data.shangpingHeight);
      })


      query2.select('.pinlun').boundingClientRect()
      query2.exec(function (res) {
        //res就是 该元素的信息 数组
        console.log(res);
        //取高度
        _this.setData({
          pinlunHeight: res[0].height
        })
        console.log(_this.data.pinlunHeight);
      })

      query3.select('.xiangqin').boundingClientRect()
      query3.exec(function (res) {
        //res就是 该元素的信息 数组
        console.log(res);
        //取高度
        _this.setData({
          xiangqinHeight: res[0].height
        })
        console.log(_this.data.xiangqinHeight);
      })

      query4.select('.fixedhead').boundingClientRect()
      query4.exec(function (res) {
        //res就是 该元素的信息 数组
        console.log(res);
        //取高度
        _this.setData({
          headHeight: res[0].height
        })
        console.log(_this.data.headHeight);
      })
    },
    onPageScroll: function (e) {
      this.setData({'scrollnum':e.scrollTop})
    },
    spact:function(){
      this.setData({'scrollnum':0})
      wx.pageScrollTo({
        scrollTop: this.data.scrollnum
      })
    },
    plact: function () {
      this.setData({ 'scrollnum': this.data.shangpingHeight - this.data.headHeight })
      wx.pageScrollTo({
        scrollTop: this.data.scrollnum
      })
    },
    xqact: function () {
      this.setData({ 'scrollnum': this.data.shangpingHeight + this.data.pinlunHeight - this.data.headHeight+2 })
      wx.pageScrollTo({
        scrollTop: this.data.scrollnum
      })
    },
    watchnumber:function(e){
      this.setData({'number':e.detail.value})
      console.log(this.data.number)
      if (this.data.number<=0){
        this.setData({ 'number': 1 })
      }
    },
    redusnumber:function(){
      if (this.data.number<=1){
        this.setData({ 'number': 1 })
      }else{
        this.setData({ 'number': this.data.number - 1 })
      }
    },
    addnumber: function () {
      this.setData({ 'number': this.data.number + 1 })
    },
    imglook:function(e){
      var aa = e.target.dataset.atlasth;
      var bb = e.target.dataset.src;
      wx.previewImage({
        current: bb, 
        urls: aa 
      })
    },
    sc:function(){
      this.setData({'scact': !this.data.scact})
    },
    addcar:function(){
      wx.showToast({
        title: '加入购物车成功',
        icon: 'success',
        duration: 2000
      })
    },
    layboxclick: function (){
      this.setData({ 'layact': !this.data.layact })
     
    },
    tcxzk:function(){
      this.setData({ 'layact': !this.data.layact })
      
    },
    tj:function(){
      this.setData({ 'layact': !this.data.layact })
    }
  }
})
